// window.onload = function(){
//     var iframe = document.getElementById("pageContent");
//     if (iframe.attachEvent) {    
//         iframe.attachEvent("onload", function() {    
//             document.getElementById("pageContent").contentWindow.document.getElementById("operateBtn_4").click();
//         });    
//     } else {    
//         iframe.onload = function() {    
//             document.getElementById("pageContent").contentWindow.document.getElementById("operateBtn_4").click();
//         }
//     }
// }

// window.onload = function() {
//     document.getElementById("pageContent").onload = function() {    
//         alert(document.getElementById('pageContent').src);
//         window.location.href = document.getElementById('pageContent').src;
//     }
// }
window.onload = function() {
    setTimeout(function(){var mf = "<p style='display:inline-block;text-aligh:center;font-weight:bold;margin:5px 0;font-size:1.15em;'>自动抢课系统</p><br><p style='display:inline-block;text-aligh:center;color:red;margin:3px 0;font-weight:bold;'>Running</p>"
    var mt = document.createElement("div");
    mt.id = "mother_fucker";
    mt.style = "position: fixed;background: #fff;top: 40px;right: 40px;opacity: 0.8;padding: 10px;border-radius: 10px;box-shadow: 0px 0px 10px #aaa;";
    mt.innerHTML = mf;
    document.body.appendChild(mt);
    if (document.getElementById("resultMsg").textContent == "合格") {
        document.getElementById("mother_fucker").innerHTML = "<p style='display:inline-block;text-aligh:center;font-weight:bold;margin:5px 0;font-size:1.15em;'>自动抢课系统</p><br><p style='display:inline-block;text-aligh:center;font-weight:bold;margin:5px 0;font-size:1.15em;color:green;'>SUCCESSFUL</p>";
        document.getElementById("mother_fucker").innerHTML += "<br><p style='display:inline-block;text-aligh:center;margin:3px 0;'>预选课程："+document.getElementsByClassName('mycourse-table')[0].rows[1].cells[0].textContent;
        return;
    }
    var cname = "网页设计";
    document.getElementById("mother_fucker").innerHTML += ("<br><p style='display:inline-block;text-aligh:center;margin:3px 0;'>预选课程："+cname+"</p>");
    },1000);
    setTimeout(function() {
    var cnum = false;
    var table = document.getElementsByClassName('mycourse-table')[0].rows;
    for (var i = 0; i <= table.length - 1; i++) {
        document.getElementsByClassName('mycourse-table')[0].rows[i].style.background = "yellow";
	    if (table[i].cells[0].textContent == cname) {
		    cnum = i - 1;
            document.getElementsByClassName('mycourse-table')[0].rows[i].style.background = "green";
		    break;
	    }
    }
    if (!cnum) {alert("未找到该课程")}
    var result = document.getElementById(('operateBtn_' + cnum)).click();
    if (result) {document.getElementById("mother_fucker").innerHTML = "<p style='display:inline-block;text-aligh:center;font-weight:bold;margin:5px 0;font-size:1.15em;color:green;'>SUCCESSFUL</p>";return;}
    document.getElementById("mother_fucker").innerHTML = "<p style='display:inline-block;text-aligh:center;font-weight:bold;margin:5px 0;font-size:1.15em;color:red;'>FAILED</p>"
    },3000);
}